<?php
import("com.yado.drivers.ITableDescriptor");
import("com.mysql.yado.Table");
import("com.mysql.yado.fields.DataField");
class TableDescriptor implements ITableDescriptor {
	/**
	 * Enter description here...
	 *
	 * @var IConnection
	 */
	private $_connection;
	/**
	 * Enter description here...
	 *
	 * @return IConnection
	 */
	public function getConnection(){
		return $this->_connection;
	}
	private $_name;
	public function getName(){
		return $this->_name;
	}
	private $_fields=array();
	public function getFields(){
		return $this->_fields;
	}
	public function __construct($name,IConnection $connection){
		$this->_connection = $connection;
		$this->_name = $name;
		$this->_getDescription();
		//var_dump($this->_fields);
	}
	/**
	 * Enter description here...
	 *
	 * @param string $name
	 * @return ITable
	 */
	public function createTable(){
		return new Table($this);
	}
	
	public function __call($name,$args){
		
	}
	
	private function _getDescription(){
		$stmt = $this->_connection->prepearStatement("DESCRIBE ".$this->_name);
		$stmt->execute();
		$res = $stmt->getResultSet();
		while ($field=$res->next()){
			array_push($this->_fields,new DataField($this,$field));
		}
	}
	
}

?>